#include <iostream>
using namespace std;
#include <vector>

class Solution
{
public:
    static string longestCommonPrefix(const vector<string>& strs)
    {
        string rs = strs[0];
        for(int i=1; i<strs.size(); i++)
        {
            int cur = 0;
            while(rs[cur] && strs[i][cur] && rs[cur] == strs[i][cur])
                cur++;
            rs = rs.substr(0,cur);
        }
        return rs;
    }
};